<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class MembersModel extends Model{
    
        public function checkLogin($username, $password)
	{
		$membersInfo = $this->where(array('username' => $username))->find();
                
		if($membersInfo != null){
 
			if($membersInfo['password'] == md5($password)){
                                if($membersInfo['status'] == 0){
                                    return 2;
                                }
				$member = array(
					'uid' => $membersInfo['id'],
					'username' => $username,
                                        'real_name' => $membersInfo['real_name'],
                                        'study_status' => 0
					);
				$_SESSION['current_member'] = $member;
				return 1;
			}else{
				return 0;
			}
		}
		return -1;
	}
    
}